package com.ygxsk.carhome.ui.adapter;

import android.text.TextUtils;
import android.widget.CheckBox;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ygxsk.carhome.R;
import com.ygxsk.carhome.response.HouseAuthBean;
import com.ygxsk.carhome.utils.CommUtils;

import java.util.List;

/*
 * @Author:itchenqi175@163.com
 * @Time:2023/12/28  15:22
 * @Description: 选择房间的列表内容的适配器内容
 */
public class SelecetRoomAdapter extends BaseQuickAdapter<HouseAuthBean, BaseViewHolder> {

    public SelecetRoomAdapter(int layoutResId, @Nullable List<HouseAuthBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, HouseAuthBean item) {

        if (item != null) {

            CheckBox checkBoxSeletcItem = (CheckBox) baseViewHolder.getView(R.id.imagepaymentselectinroom);
            //最后一条数据的布局
            TextView textViewCheckBoxHelp = (TextView) baseViewHolder.getView(R.id.textviewcheckboxhelp);

//            CommUtils.setButtonDrawable(checkBoxSeletcItem);

            //做非空等判断处理将来
            //String  propertyName =item.get();
            //String  communityName = item.getCommunityName();

            //String firstTextView = "";

            //普通其他的功能模块 是这个字段
            String houseAddress = item.getHouseAddress();

            //String  buildingName =item.getBuildingName();
            String roomNumber = item.getHouseNo();
            //String  roomType ="房间";//item.getRoomType();//这里房产类型默认为房间。 2018年03月09日去掉房产类型
            int isChecked = item.getChecked();
            if (isChecked == 0) {
                checkBoxSeletcItem.setChecked(false);
            } else if (isChecked == 1) {
                checkBoxSeletcItem.setChecked(true);
            }

            int indexPosition = getItemPosition(item);
            if (indexPosition == getData().size() - 1) {
                CommUtils.setViewGone(textViewCheckBoxHelp);
            } else {
                CommUtils.setViewVisible(textViewCheckBoxHelp);
            }

            //有个图片按钮内容
            //物业名称,2018年03月09日去掉该功能，放在二期。
            //helper.setText(R.id.textViewpropertyname,propertyName);

            //2020年8月17日09:58:10 如果是从【物品借用】模块过来的，那么就用communityName字段
            //如果不是 物品借用 模块过来的，就是用houseAddress字段

            baseViewHolder.setText(R.id.textviecommunityname, TextUtils.isEmpty(houseAddress) ? "" : houseAddress);

            //helper.setText(R.id.textviewbuillding,TextUtils.isEmpty(buildingName)?"":buildingName);
            baseViewHolder.setText(R.id.textroomnumber, TextUtils.isEmpty(roomNumber) ? "" : roomNumber);
            //helper.setText(R.id.textroomnumtype,roomType);//房产类型

            //选择房间图片的点击事件内容。去掉该绑定的点击事件。layoutcheckboxinroom
            //helper.addOnClickListener(R.id.layoutcheckboxinroom);

        }

    }
}
